package com.neo.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neo.model.User;
import com.neo.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class HelloWorldController {

    @Resource
    private UserService userService;


    @RequestMapping("/hello")
    public String index() {
        System.out.println("Hello World");
        return "Hello World";
    }

    @RequestMapping("/getAllUsers")
    public String getAllUsers() {
        System.out.println("getAllUsers");
        //        //分页查询数据，每页显示5条，
        Page<User> userPage = new Page<>(1, 10);
        //分页查询的结果
        Page<User> page = userService.page(userPage, null);
        List<User> userList = userService.getUserByUserAge("10");
        System.out.println(userList.toString());
        return "Hello World2";
    }

    @RequestMapping("/testDoris")
    public String testDoris() {
        List<User> userList = userService.getUser();
        System.out.println(userList.toString());
        return "testDoris";
    }


    @RequestMapping("/testMysql")
    public String testMysql() {
        List<User> userList = userService.getUser();
        System.out.println(userList.toString());
        return "testMysql";
    }

}